unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, RzButton, RzRadChk,
  OverbyteIcsWndControl, OverbyteIcsHttpSrv, Vcl.Menus, rtcInfo, rtcConn,
  rtcDataSrv, rtcHttpSrv,Class_KzUtils,Class_KzDebug;

type
  TForm1 = class(TForm)
    HttpServer1: THttpServer;
    Chkb_1: TRzCheckBox;
    mm1: TMainMenu;
    Menu_N1: TMenuItem;
    Menu_N2: TMenuItem;
    HtpSrv_1: TRtcHttpServer;
    procedure Chkb_1Click(Sender: TObject);
    procedure HttpServer1GetDocument(Sender, Client: TObject;
      var Flags: THttpGetFlag);
    procedure Menu_N2Click(Sender: TObject);
    procedure HttpServer1PostDocument(Sender, Client: TObject;
      var Flags: THttpGetFlag);
    procedure HttpServer1ConnectDocument(Sender, Client: TObject;
      var Flags: THttpGetFlag);
    procedure HttpServer1PostedData(Sender, Client: TObject; Error: Word);
  private
  public
  end;

var
  Form1: TForm1;

implementation

uses
  Class_KzDebug,Winapi.ShellAPI;

{$R *.dfm}

procedure TForm1.Chkb_1Click(Sender: TObject);
begin
  self.HttpServer1.Port:='9001';
  self.HttpServer1.ClientClass:=THttpConnection;
  if TRzCheckBox(Sender).Checked then
  begin
    self.HttpServer1.Start;
  end else
  begin
    self.HttpServer1.Stop;
  end;
end;

procedure TForm1.HttpServer1ConnectDocument(Sender, Client: TObject;
  var Flags: THttpGetFlag);
begin
  //
end;

procedure TForm1.HttpServer1GetDocument(Sender, Client: TObject;
  var Flags: THttpGetFlag);
var
  ClientCnx:THttpConnection;
begin
  ClientCnx:=THttpConnection(Client);
  KzDebug.FileFmt([self.ClassName,ClientCnx.Path,ClientCnx.ReqTarget,ClientCnx.Params,ClientCnx.Version]);
  ClientCnx.AnswerString(Flags,'','','','httpserver1getdocument:hello,world,ics');
end;

procedure TForm1.HttpServer1PostDocument(Sender, Client: TObject;
  var Flags: THttpGetFlag);
var
  ClientCnx:THttpConnection;
begin
  ClientCnx:=THttpConnection(Client);
  KzDebug.FileFmt([self.ClassName,ClientCnx.Path,ClientCnx.ReqTarget,ClientCnx.Params,ClientCnx.Version]);
  //ClientCnx.AnswerString(Flags,'','','','httpserver1postdocument:hello,world,ics');
  Flags:=hg403;
end;


procedure TForm1.HttpServer1PostedData(Sender, Client: TObject; Error: Word);
var
  ClientCnx:THttpConnection;
  Dummy  : THttpGetFlag;
begin
  ClientCnx:=THttpConnection(Client);
  KzDebug.FileFmt([self.ClassName,ClientCnx.Path,ClientCnx.ReqTarget,ClientCnx.Params,ClientCnx.Version]);
  ClientCnx.AnswerString(Dummy,'','','','HttpServer1PostedData:hello,world,ics');
end;

procedure TForm1.Menu_N2Click(Sender: TObject);
begin
  ShellExecute(Handle,'open','explorer.exe',PChar(TKzUtils.ExePath),'',SW_MAXIMIZE);
end;

end.
